#ifndef __WEBPAGEQUERY_HPP__
#define __WEBPAGEQUERY_HPP__

#include <string>
#include <vector>
#include <unordered_map>
#include <set>

using std::string;
using std::vector;
using std::pair;
using std::unordered_map;
using std::set;

class WebPage;

//网页查询类
class WebPageQuery
{
public:
    WebPageQuery() {}
    ~WebPageQuery() {}

    string doQuery(const string& str);
    
private:
    void loadLibrary();
    vector<double> getQueryWordsWeightVector(vector<string>& queryWords);
    bool executeQuery(const vector<string>& queryWords,vector<pair<int,vector<double>>>& resultVec);
    string createJson(vector<int>& docIdVec,const vector<string>& queryWords);
    string returnNoAnswer();

private:
    WordSegmentation _jieba;
    unordered_map<int,WebPage> _pageLib;
    unordered_map<int,pair<int,int>> _offsetLib;
    unordered_map<string,set<pair<int,double>>> _invertIndexTable;

};


#endif
